package com.ziyun.erp.web.modules.service.controller;

import com.ziyun.erp.modules.service.entity.ServiceSendGoodsEntity;
import com.ziyun.erp.modules.service.service.ServiceSendGoodsService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 售后发货表
 *
 * @author zh
 * @email 296588519@qq.com
 * @date 2018-08-28 15:41:42
 */
@RestController
@RequestMapping("service/servicesendgoods")
public class ServiceSendGoodsController {
    @Autowired
    private ServiceSendGoodsService serviceSendGoodsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("service:servicesendgoods:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = serviceSendGoodsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{ssgId}")
    @RequiresPermissions("service:servicesendgoods:info")
    public R info(@PathVariable("ssgId") Integer ssgId){
        ServiceSendGoodsEntity serviceSendGoods = serviceSendGoodsService.selectById(ssgId);

        return R.ok().put("serviceSendGoods", serviceSendGoods);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("service:servicesendgoods:save")
    public R save(@RequestBody ServiceSendGoodsEntity serviceSendGoods){
        serviceSendGoodsService.insert(serviceSendGoods);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("service:servicesendgoods:update")
    public R update(@RequestBody ServiceSendGoodsEntity serviceSendGoods){
        ValidatorUtils.validateEntity(serviceSendGoods);
        serviceSendGoodsService.updateAllColumnById(serviceSendGoods);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("service:servicesendgoods:delete")
    public R delete(@RequestBody Integer[] ssgIds){
        serviceSendGoodsService.deleteBatchIds(Arrays.asList(ssgIds));

        return R.ok();
    }

}
